<template>
	<view class="login">
		<view style="margin-top: 286rpx;margin-bottom: 30rpx;">
			<image src="../../static/logo.png" style="width: 231rpx;height: 61rpx;"></image>
			<!-- <i-icon icon="logo" size="231rpx" /> -->
		</view>
		<text>欢迎登陆奥莱小样系统</text>
		<view style="margin: 200rpx 0;width: 100%;">
			<u-input placeholder="请输入账号" placeholder-style="color: #999999;" v-model="from.user_account"
				clearable></u-input>
			<view style="height: 60rpx;"></view>
			<u-input placeholder="请输入密码" placeholder-style="color: #999999;" clearable
				password v-model="from.user_password"></u-input>
		</view>
		<ButtonConfirm myTxt="登 陆" @click="login"></ButtonConfirm>
	</view>
</template>

<script>
	import ButtonConfirm from '@/components/buttonConfirm.vue'
	import user from '@/api/user.js';
	export default {
		components: {
			ButtonConfirm
		},
		data() {
			return {
				from: {
					user_account: '', // 账号
					user_password: '', // 密码
				}

			};
		},

		methods: {
			async login() {
				const res = await user.login(this.from)
				if (res.code === 200) {
					const {
						token,
						...userinfo
					} = res.data
					uni.setStorageSync('userinfo', userinfo)
					uni.setStorageSync('token', token)
					uni.setStorageSync('isLogin', true)
					uni.switchTab({
						url: '/pages/index/equipment',
						success: () => {
							uni.showToast({
								title: '登陆成功',
								icon: "none"
							})
						}
					})
				}

			},
		},
		options: {
			styleIsolation: 'shared'
		},
	}
</script>

<style lang="scss" scoped>
	.login {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	/deep/ .u-input__content{
		margin-bottom: 20rpx;
	}
	/deep/ .u-input {
		border-radius: 0 !important;
		border: 0 !important;
		border-bottom: 1px solid #D8D8D8 !important;
		margin: 0 62rpx;
		color: #D8D8D8;
	}
</style>